#include "unionteccontrollerhmiinstance.h"
#include "unionteccontrollerhmiinstance_global.h"

static UnionTecControllerHMIInstance* pUnionTecControllerHMIInstance = nullptr;

short PLU_TecControllerHMIInstanceCreate(){
    if(pUnionTecControllerHMIInstance == nullptr){
        pUnionTecControllerHMIInstance = new UnionTecControllerHMIInstance();//实例化出一个指向搅拌工艺插件实例的指针
    }
    return 1;
}

short PLU_TecControllerHMIInstanceDelete(){
    if(pUnionTecControllerHMIInstance != nullptr){
        delete pUnionTecControllerHMIInstance;
    }
    return 1;
}

QWidget* PLU_TecControllerHMIIInstanceUiRegesiter(){
    return pUnionTecControllerHMIInstance->getUiHandle();
}

void TASK_uifast_plugin(){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->timer_PluginFastTimerLoop();
    }
}
void TASK_uislow_plugin(){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->timer_PluginSlowTimerLoop();
    }
}

void SLOTS_btnHomeClicked(){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->slots_onbtnclicked_Home();
    }
}
void SLOTS_btnVisHmiClicked(){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->slots_onbtnclicked_VisHmi();
    }
}

void SLOTS_btnSettingClicked(){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->slots_onbtnclicked_Setting();
    }
}
void SLOTS_btnEditClicked(){

}
bool SLOTS_btnPauseClicked(){
    return 1;
}
bool SLOTS_btnRunClicked(){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->slots_onbtnclicked_Run();
        return 1;
    }
    return 0;
}
bool SLOTS_btnStopClicked(){
    return 1;
}

void SLOTS_btnfn1Clicked(){

}
void SLOTS_btnfn2Clicked(){

}
void SLOTS_btnfn3Clicked(){

}
void SLOTS_btnfn4Clicked(){

}
void SLOTS_btnMainScriptStatusClicked(){

}

void MES_fromBackendMessageCommand(QByteArray Data){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->message_fromBackendMessageCommand(Data);
    }
}
void MES_toBackendMessage(QByteArray& Data){
    if(pUnionTecControllerHMIInstance != nullptr){
        pUnionTecControllerHMIInstance->message_toBackendMessage(Data);
    }
}
